Skip to content

Conversation

@ObayM
Copy link

@ObayM ObayM commented Nov 24, 2024

This PR introduces the PythonParser class, which utilizes the web-tree-sitter library to analyze Python code. The main features added in this PR include:

Initialization of Tree-Sitter Parser:

The PythonParser class initializes a web-tree-sitter parser for Python using the tree-sitter-python grammar.
It loads the WebAssembly module (tree-sitter-python.wasm) to set up the parsing environment.

Finding Enclosing Context:

The findEnclosingContext method identifies the largest enclosing function or class definition given a range of lines.
This method provides context information about the type (function, async function, or class), name, and location of the enclosing code block.
Syntax Validation:

The dryRun method performs a syntax check on the provided Python code.
It parses the code to identify any syntax errors and returns whether the code is valid or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant